package com.collectionAndMap.collection.set;

import java.util.TreeSet;

/***
 * @ClassName: test
 * @Description:
 * @Auther: 送一一块二向箔
 * @Date: 17:14 2022/2/17
 * @version : V1.0
 */
public class test {
    public static void main(String[] args) {

        aaa();
    }
    public static void aaa() {
        TreeSet<String> set = new TreeSet<>((a,b)->{
            int lengtha = a.length();
            int lengthb = b.length();
            int count =lengtha-lengthb ;
            if(count > 0 ){
                return 1;
            }else if (count < 0){
                return -1;
            }else {
                for (int i = 0; i < lengtha; i++) {
                    if(a.charAt(i) > b.charAt(i)){
                        return 1;
                    }else if(a.charAt(i) < b.charAt(i)){
                        return -1;
                    }
                }
                return 0;
            }
        });


        set.add("qrwer");
        set.add("safasdfd");
        set.add("dasfasedf");
        set.add("utyuyt");
        set.add("yhtru");
        set.add("sdfgs");
        System.out.println(set.toString());


    }
}
